import { createRouter, createWebHashHistory } from 'vue-router'
import Home from '../views/Home.vue'

const routes = [

  {
    path: '/pro_inject',
    name: 'pro_inject',
    meta: {
      keepAlive: false,
      title: "pro_inject"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/student_vue/pro_inject/index.vue')
  },
  {
    path: '/student_telopolt',
    name: 'student_telopolt',
    meta: {
      keepAlive: false,
      title: "student_telopolt"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/student_vue/telepolt_com/index.vue')
  },
  {
    path: '/student_async_com',
    name: 'student_async_com',
    meta: {
      keepAlive: false,
      title: "student_telopolt"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/student_vue/async_components')
  },
  {
    path: '/student_vuex',
    name: 'student_vuex',
    meta: {
      keepAlive: false,
      title: "student_vuex"
    },
    component: () => import('../views/student_vue/student_vuex/index.vue')
  },
  {
    path: '/emits_event',
    name: 'emits_event',
    meta: {
      keepAlive: false,
      title: "emits_event"
    },
    component: () => import('../views/student_vue/emits_event/index.vue')
  },
  {
    path: '/scroll_best',
    name: 'scroll_best',
    meta: {
      keepAlive: false,
      title: "scroll_best"
    },
    component: () => import('../views/student_vue/scroll/index.vue')
  },




  // 项目开始

  {
    path: '/',
    name: 'Home',
    meta: {
      keepAlive: false,
      title: "home首页"
    },
    component: Home
  },
  {
    path: '/about',
    name: 'About',
    meta: {
      keepAlive: false,
      title: "about首页"
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

//挂载路由导航守卫
router.beforeEach((to, from, next) => {
  document.title = to.meta.title
  next()
  // if (to.path === "/login") {
  //   return next()
  // } else {
  //   //获取在登陆时返回数据里面保存在内存中的token值
  //   let token = window.localStorage.getItem("token")

  //   if (!token) {
  //     return next("/login")
  //   } else {
  //     next()
  //   }
  // }
})

export default router
